package com.hhl.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.hhl.dao.UserDao;
import com.hhl.entity.User;
import com.hhl.mapper.UserMapper;
import com.hhl.test01.dao.UserMapper01;
import com.hhl.test02.dao.UserMapper02;

@Service
public class UserService {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private UserDao userDao;
	@Autowired
	UserMapper userMapper;
	
	@Autowired
	UserMapper01 userMapper01;
	@Autowired
	UserMapper02 userMapper02;
	
	
	public void addUser(String name,String age){
		System.out.println("创建用户开始");
		jdbcTemplate.update("insert into user(name,age) values(?,?);",new Object[] {name,age});
		System.out.println("创建用户成功");
	}
	
	public void addJpaUser(String name,Integer age){
		System.out.println("创建用户开始");
		User user = new User();
		user.setName(name);
		user.setAge(age);
		userDao.save(user);
		System.out.println("创建用户成功");
	}
	
	public void addMybatisUser(String name,Integer age){
		userMapper.insert(name, age);
	}
	
	
	public void addMybatisUser01(String name,Integer age){
		userMapper01.insert(name, age);
	}
	
	public void addMybatisUser02(String name,Integer age){
		userMapper02.insert(name, age);
	}
}
